//
//  RHDeviceParaCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/10/28.
//

#import "RHDeviceParaCell.h"
@interface RHDeviceParaCell()
@property (nonatomic, strong) QMUILabel *titleLab;

@property (nonatomic, strong) UIView *bgView;
@end
@implementation RHDeviceParaCell
-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        [self setupUI];
    }
    return self;
}

- (void)setParaModel:(DeviceChartFieldModel *)paraModel
{
    _paraModel = paraModel;
    if(paraModel.isSelected){
        self.titleLab.textColor = [UIColor whiteColor];
        [self.bgView setGradientBackgroundWithColors:@[kCOLOR_HEX(@"6AD785"),kCOLOR_HEX(@"5ECBB7")] locations:@[@(0),@(1)] startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5)];
       
    }else{
        self.titleLab.textColor = [UIColor colorWithHexString:@"3F4443" alpha:0.6];
        [self.bgView setGradientBackgroundWithColors:@[kCOLOR_HEX(@"F6F8FA"),kCOLOR_HEX(@"F6F8FA")] locations:@[@(0),@(1)] startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5)];
    }
    self.titleLab.text = paraModel.keyCode;
}

-(void)setupUI
{
    kWeakSelf;
    self.contentView.backgroundColor = [UIColor whiteColor];
    UIView *bgView = kView;
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.cornerRadius = 8;
    bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:bgView];
    self.bgView = bgView;
   
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsZero);
    }];
    
    
    _titleLab = [[QMUILabel alloc]init];
    _titleLab.text = @"85,796";
    _titleLab.font = kSYSTEMFONT(13);
    _titleLab.textAlignment = NSTextAlignmentCenter;
    _titleLab.numberOfLines = 0;
    _titleLab.textColor = kCOLOR_HEX(@"3F4443");
    [bgView addSubview:_titleLab];
    
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(5);
        make.right.mas_offset(-5);
        make.centerY.mas_offset(0);
    }];
    
   
    
    
   
}
@end
